<template>
	<view>
		<city-select
			@cityClick="cityClick"
			:activeCity="activeCity"
			:hotCity="hotCity"
			:obtainCitys="obtainCitys"
			:isSearch="true"
			ref="citys"
		></city-select>
	</view>
</template>

<script>
	import citySelect from '@/components/city-select/city-select.vue';
	export default {
		components: {
			citySelect
		},
		data() {
			return {
				//当前城市
				activeCity: '',
				//热门城市
				hotCity: [],
				//显示的城市数据
				obtainCitys: []
			};
		},
		onLoad(options) {
			console.log(options)
			let title
			if(options.type == 'end'){
				title = "请选择出发城市"
			}else{
				title = "请选择到达城市"
			}
			uni.setNavigationBarTitle({
				title:title
			})
			this.getCity()
		},
		methods: {
			getCity(){
				this.$https.get('public/city').then(res=>{
					// this.nowRoutes = res.in
					this.obtainCitys = res.indexGroupCityList;
				})
			},
			cityClick(item) {
				uni.setStorageSync('city',item);
				uni.navigateBack({
					delta:1
				})
				// uni.showToast({
				// 	icon: 'none',
				// 	title: 'item: ' + JSON.stringify(item),
				// 	// #ifdef MP-WEIXIN
				// 	duration: 3000,
				// 	// #endif
				// 	mask: true
				// });
			}
		}
	}
</script>

<style lang="less">

</style>
